<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="service.*,pojo.*,java.util.List" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function editNum(i){
	//获取数量和c_id
	//var cid=document.getElementsById("c_id")[i].value;
	//var num=document.getElementsById("quantity")[i].value;
	var cid=document.getElementById("c_id"+i).value;
	var num=document.getElementById("quantity"+i).value;
	alert(cid+" "+num);
	window.location="edit.jsp?cid="+cid+"&num="+num;
}
function submitOrder(){
	
}
</script>
</head>
<body>
<h1>购物车</h1>
<form action="order.jsp">
<table border="1">
<%
Customer cu =(Customer)(session.getAttribute("c"));
CartService cservice=new CartService();
Cart rt=new Cart();
//调用showCustomer方法
List<Cart> list = cservice.showCartsByUID(cu.getC_name());
for(int i=0;i<list.size();i++){//对list集合进行循环输出
	 Cart cart = list.get(i);
%>
<tr>
<td><input type="checkbox" name="cc_id" value="<%=cart.getC_id()%>"/></td>
<td><img src="<%=cart.getP_image() %>" width="100px" height="50px"></td>
<td><%=cart.getP_name() %></td>
<td><%=cart.getP_price() %></td>
<td>
<input type="hidden" value="<%=cart.getC_id()%>" id="c_id<%=i%>"/>
<input type="text" value="<%=cart.getQuantity() %>" id="quantity<%=i%>"/>
<button onclick="editNum(<%=i%>)">编辑</button></td>
<td><%=cart.getAmount() %></td>
<td><a href="<%=request.getContextPath()%>/CartServlet?method=del&cid=<%=cart.getC_id()%>">删除</a></td>
</tr>
<%} %>
<h2>
<input type="submit" value="提交订单"/>
</h2>
</table>
</form>
</body>
</html>